Three Sorting Algorithms Using Priority Queues
نویسنده
چکیده
We establish a lower bound of B(n) = ndlogne−2dlogne +1 on the number of comparisons performed by any algorithm that uses priority queues to sort n elements. Three sorting algorithms using priority queues are introduced. The first algorithm performs the same comparisons as the classical Mergesort algorithm, but in a different order. The second algorithm performs at most 2n logn+O(n) comparisons, with the advantage of being adaptive; meaning that it runs faster when the input sequence has some presortedness. In particular, we show that this algorithm sorts an already sorted sequence in linear time; a fact that is not obvious since there is no special checks to guarantee this behavior. The third algorithm is almost implicit; it can be implemented using the input array and less than n extra bits. The number of comparisons performed by this algorithm is at most B(n) + 2.5n. The three algorithms have the advantage of producing every element of the sorted output, after the first, in O(logn), and can be implemented to be practically efficient.
منابع مشابه
2 Priority Queue
In the last lecture, we discussed algorithms for integer sorting. In this lecture we will discuss the relationship between integer sorting algorithms and priority queue data structures. It is obvious that fast priority queues imply fast sorting, since if a priority queue can do Insert and Deletemin in O(f(n)), then we can sort in O(nf(n)) by inserting all elements into the queue then calling De...
متن کاملTwo Constant-Factor-Optimal Realizations of Adaptive Heapsort
In this paper we introduce two efficient priority queues. For both, insert requires O(1) amortized time and extract-min O(lgn) worstcase time including at most lgn+O(1) element comparisons, where n is the number of elements stored. One priority queue is based on a weak heap (array-based) and the other on a weak queue (pointer-based). In both, the main idea is to temporarily store the inserted e...
متن کاملAn Experimental Study of Word-level Parallelism in Some Sorting Algorithms
A number of algorithms for fundamental problems such as sorting, searching, priority queues and shortest paths have been proposed recently for the unit-cost RAM with word size w. These algorithms ooer dramatic (asymptotic) speedups over classical approaches to these problems. We describe some preliminary steps we have taken towards a systematic evaluation of the practical performance of these a...
متن کاملEquivalence between Priority Queues and Sorting in External Memory
A priority queue is a fundamental data structure that maintains a dynamic ordered set of keys and supports the followig basic operations: insertion of a key, deletion of a key, and finding the smallest key. The complexity of the priority queue is closely related to that of sorting: A priority queue can be used to implement a sorting algorithm trivially. Thorup [11] proved that the converse is a...
متن کاملA Framework for Speeding Up Priority-Queue Operations
We introduce a framework for reducing the number of element comparisons performed in priority-queue operations. In particular, we give a priority queue which guarantees the worst-case cost of O(1) per minimum finding and insertion, and the worst-case cost of O(log n) with at most log n+O(1) element comparisons per minimum deletion and deletion, improving the bound of 2 logn+ O(1) on the number ...
متن کامل